package org.example;

import java.util.Arrays;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:何人亮
 * Date:2024-10-19
 * 19:15
 */
import java.util.Scanner;
class Test{
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String s=sc.nextLine();
        String ss=s.toLowerCase();

        int count=0;
        while(sc.hasNext()){
            String s2=sc.nextLine();
            if(s2.equals("end")){
                break;
            }
            String ss2=s2.toLowerCase();
            String[] s3=ss2.split(" ");
            for(int i=0;i<s3.length;i++){
                if(s3[i].equals(s)){
                    count++;
                }
            }
        }
        System.out.println(count);
    }
}